/**
 * 
 */
package com.mobi.Survey.controller;

import android.graphics.Bitmap;

/**
 * @author yahya
 * 
 */
public final class User
{

	private boolean user;

	private boolean active;
	private boolean advertisement;
	private boolean showAds;

	private Image listImage = new Image(null, 1);
	private Image detailImage = new Image(null, 1);

	/**
	 * @return the active
	 */
	public boolean isActive()
	{
		return active;
	}

	/**
	 * @param active
	 *            the active to set
	 */
	public void setActive(boolean active)
	{
		this.active = active;
	}

	/**
	 * @return the advertisement
	 */
	public boolean isAdvertisement()
	{
		return advertisement;
	}

	/**
	 * @param advertisement
	 *            the advertisement to set
	 */
	public void setAdvertisement(boolean advertisement)
	{
		this.advertisement = advertisement;
	}

	/**
	 * @return the showAds
	 */
	public boolean isShowAds()
	{
		return showAds;
	}

	/**
	 * @param showAds
	 *            the showAds to set
	 */
	public void setShowAds(boolean showAds)
	{
		this.showAds = showAds;
	}

	/**
	 * @return the listImage
	 */
	public Image getListImage()
	{
		return listImage;
	}

	/**
	 * @param listImage
	 *            the listImage to set
	 */
	public void setListImage(Image listImage)
	{
		this.listImage = listImage;
	}

	/**
	 * @return the detailImage
	 */
	public Image getDetailImage()
	{
		return detailImage;
	}

	/**
	 * @param detailImage
	 *            the detailImage to set
	 */
	public void setDetailImage(Image detailImage)
	{
		this.detailImage = detailImage;
	}

	public boolean isUser()
	{
		return user;
	}

	public void setUser(boolean user)
	{
		this.user = user;
	}

	private static User instance = null;

	private User()
	{
	}

	public void release()
	{
		this.listImage.release();
		this.detailImage.release();

		User.instance = null;

	}

	public static synchronized User getInstance()
	{
		if (instance == null)
		{
			instance = new User();
		}
		return instance;
	}

	public static final class Image
	{
		private String url;
		private Bitmap bitmap;
		private float percentHeight;
		private float percentWidth = 10;

		public void release()
		{
			if (this.bitmap != null && !this.bitmap.isRecycled())
			{
				this.bitmap.recycle();
				this.bitmap = null;
			}
			this.url = null;
			this.percentHeight = 0;
			this.percentWidth = 0;
		}

		/**
		 * @return the percentHeight
		 */
		public float getPercentHeight()
		{
			return percentHeight;
		}

		/**
		 * @param percentHeight
		 *            the percentHeight to set
		 */
		public void setPercentHeight(float percentHeight)
		{
			this.percentHeight = percentHeight;
		}

		/**
		 * @return the url
		 */
		public String getUrl()
		{
			return url;
		}

		/**
		 * @return the percentWidth
		 */
		public float getPercentWidth()
		{
			return percentWidth;
		}

		public Image(String url, float percentHeight)
		{
			super();
			this.url = url;
			this.percentHeight = percentHeight;
		}

		/**
		 * @param url
		 *            the url to set
		 */
		public void setUrl(String url)
		{
			this.url = url;
		}

		/**
		 * @param percentWidth
		 *            the percentWidth to set
		 */
		public void setPercentWidth(float percentWidth)
		{
			this.percentWidth = percentWidth;
		}

		/**
		 * @return the bitmap
		 */
		public Bitmap getBitmap()
		{
			return bitmap;
		}

		/**
		 * @param bitmap
		 *            the bitmap to set
		 */
		public void setBitmap(Bitmap bitmap)
		{
			this.bitmap = bitmap;
		}

	}

}
